<html>
<head>
<title>IMG to base64</title>
<script>
document.onpaste = function (pasteEvent) {
	const item = pasteEvent.clipboardData.items[0];
	if (item.type.indexOf("image") === 0) {
		const blob = item.getAsFile();
		const reader = new FileReader();
		reader.onload = function (event) {
			//console.log(blob);
			//console.log(reader);
			//console.log(event);
			document.getElementById("image").src = event.target.result;
			document.getElementById("text").value = event.target.result;
		};
		reader.readAsDataURL(blob);
	}
}
</script>
</head>
<body>
<textarea id="text" rows=5 cols=50></textarea><br/>
<img id="image" src="" alt="paste img"/>
</body>
</html>